#pragma once
#include "Dshow.h"
//#include <initguid.h>
#include "atlbase.h"
#include "miifilter.h"
#include "wxutil.h"
#include "..\..\include\imp_typedefine.h"
#include "..\..\include\imp_mm_wrapper.h"
//#include <map>
//using namespace std;

typedef void (*dx_video_cb_type)(Int8 *pBuffer, UInt32 pts, Int32 width, Int32 height, Int32 mediaType);
typedef void (*dx_audio_cb_type)(Int8 *pBuffer, UInt32 pts, Int32 size, Int32 sample_rate, Int32 ch, Int32 sb);

//typedef map<Int32,WCHAR*>  DEVICE_LIST;

class CMonitorGraph
{
public:
	CMonitorGraph(dx_video_cb_type video_cb, dx_audio_cb_type audio_cb);
public:
	virtual ~CMonitorGraph(void);
public:
	BOOL StartShow(void);
	BOOL StopShow(void);
	BOOL SetNightMode(bool bOn);
	void GetCameraParam(e_impmm_cam_param param, void *value);
	BOOL SetCamera();
protected:
	BOOL AddCaptureFilter(void);
	BOOL AddAudioCaptureFilter(void);
	BOOL AddMiiShowFilter(void);
	bool RemoveMiiShowFilter(void);
	bool RemoveCaptureFilter(void);
	bool RemoveAllFilter(void);
    HRESULT RemoveFilter(IGraphBuilder * inGraph, IBaseFilter * inFilter);
    bool SetAudioProperties();
	BOOL SetVideoResolution(SIZE *pSize);
	HRESULT GetFirstCamDriver( WCHAR *pwzName );
	BOOL GetDefaultProperty(long Property);
	BOOL QueryDeviceCategory(GUID inCategory);
	
	
    CComPtr<IGraphBuilder> m_pGraphBuilder;
	CComPtr<ICaptureGraphBuilder2>  m_pCaptureBuilder;
	CComPtr<IBaseFilter> m_pVideoCaptureFilter;
	CComPtr<IBaseFilter> m_pAudioCaptureFilter;
	CComPtr<IPin> m_pVideoCapturePinOutput;
    CComPtr<IPin> m_pAudioCapturePinOutput;
	CComPtr<IBaseFilter> m_pMiiShowFilter;
	CComPtr<IPin> m_pMiiShowPinInput;
	CComPtr<IPin> m_pMiiShowPinInputAudio;
	CComPtr<IAMVideoProcAmp> m_pVideoProcAmp;
	CMiiFilter * m_Show; //CMiiFilter
    CCritSec m_csLock;
	AM_MEDIA_TYPE *m_pVideoType;
	SIZE m_cap_size;
	e_impmm_cam_data m_Camera_Front_Back;
	e_impmm_cam_data m_Camera_Night;
	long m_Brightness_Normal;
	long m_Brightness_Night;
	long m_Flags;
	int m_nResolutionWidth;
	int m_nResolutionHeight;
	//DEVICE_LIST m_List;
};
